<template>
	<div class="personnelList">
		<el-breadcrumb separator="/">
			<el-breadcrumb-item :to="{ path: '/' }"><i class="lh lh-sys fw_100"></i></el-breadcrumb-item>
			<el-breadcrumb-item>系统设置</el-breadcrumb-item>
			<el-breadcrumb-item>计价规则</el-breadcrumb-item>
		</el-breadcrumb>
		<div class="content_Box box-shadow mt_15">
			<div class="py_5 px_10">
				<el-row>
					<!-- <el-col :span="2">
						<el-button type="success" class="fl" @click="goToTag()" round size="mini">新增计价</el-button>
					</el-col> -->
					<el-col :span="22">
						<el-form :inline="true" class="form-inline fr" @keyup.enter.native="shearchBtn()">
							<lh-agent-list @sendValue="setValue" :reset="agent_reset"></lh-agent-list>

							<el-form-item class="w_120">
								<el-select v-model="city_arr" placeholder="城市" @change="changeBtndialog">
									<el-option
										v-for="item in cityList"
										:key="item.id"
										:label="item.name"
										:value="`${item.id}|${item.name}`"
									></el-option>
								</el-select>
							</el-form-item>
							<el-form-item>
								<el-select v-model="s_time_slot" multiple collapse-tags placeholder="商圈" @change="shearchBtn">
									<el-button
										size="mini"
										type="primary"
										class="round-right all-area"
										@click="selectAllArea()"
										native-type="button"
										>{{ areaStatus ? '全选' : '取消全选' }}</el-button
									>
									<el-option
										v-for="item in areaList"
										:key="item.id"
										:label="item.area_name"
										:value="`${item.id}|${item.area_name}`"
									></el-option>
								</el-select>
							</el-form-item>
							<el-form-item class="w_150">
								<el-autocomplete
									class="inline-input"
									v-model="shop_name"
									:fetch-suggestions="querySearch"
									placeholder="店铺名称"
									clearable
									:trigger-on-focus="true"
									@select="handleSelect"
								></el-autocomplete>
							</el-form-item>
							<el-form-item class="w_100">
								<el-select
									v-model="industry_id"
									placeholder="行业"
									@change="changeIndustry(industry_id, 'search')"
									clearable
								>
									<el-option
										v-for="item in searchIndustryArr"
										:key="item.id"
										:label="item.label_name"
										:value="item.id"
									></el-option>
								</el-select>
							</el-form-item>
							<el-form-item class="w_100">
								<el-select v-model="type_arr" placeholder="岗位" @change="changeBtndialogtype" clearable>
									<el-option
										v-for="item in mesarr"
										:key="item.id"
										:label="item.label_name"
										:value="`${item.id}|${item.label_name}`"
									></el-option>
								</el-select>
							</el-form-item>
							<el-form-item class="w_100">
								<el-select v-model="status" placeholder="状态" clearable>
									<el-option label="启用" value="1"></el-option>
									<el-option label="已停用" value="2"></el-option>
								</el-select>
							</el-form-item>
							<el-button size="mini" type="primary" native-type="button" class="round-right" @click="shearchBtn"
								>搜索</el-button
							>
							<el-button size="mini" round @click="resetBtn">重置</el-button>
						</el-form>
					</el-col>
				</el-row>
			</div>
			<div class="tableMaxBox">
				<template>
					<el-table :data="demandList" stripe>
						<el-table-column prop="id" label="编号" align="center"></el-table-column>
						<el-table-column prop="industry_name" label="所属行业"></el-table-column>
						<el-table-column prop="label_name" label="岗位"></el-table-column>
						<el-table-column prop="label_name" label="计价方式">
							<template>
								<span>小时</span>
							</template>
						</el-table-column>
						<el-table-column prop="price_b" width="100" label="店铺单价">
							<template slot-scope="{ row }">
								<span class="text-danger">{{ row.price_b | filterNumber }}元/小时</span>
							</template>
						</el-table-column>
						<el-table-column prop="price_b" width="100" label="劳动者单价">
							<template slot-scope="{ row }">
								<span class="text-danger">{{ row.price_c | filterNumber }}元/小时</span>
							</template>
						</el-table-column>
						<!-- <el-table-column prop="price_c" label="单价" width="70px;"></el-table-column> -->
						<el-table-column prop="city_name" label="城市" width="70px;"></el-table-column>
						<el-table-column prop="area_name" label="执行商圈"></el-table-column>
						<el-table-column prop="shop_name" min-width="200" label="执行店铺"></el-table-column>
						<el-table-column prop="creater_name" label="状态" width="70px;">
							<template slot-scope="{ row }">
								<span class="text-success" v-if="row.status == '1'">启用</span>
								<span class="text-danger" v-if="row.status == '2'">已停用</span>
							</template>
						</el-table-column>
						<el-table-column prop="operate_name" label="操作人" width="100"></el-table-column>
						<el-table-column prop="last_time" label="最后操作时间" width="150"></el-table-column>
					</el-table>
					<!-- 分页组件 -->
					<page :total="total" :disableMountedFetch="true" :pageNums="pageNum" @pagedata="onChildValue"></page>
				</template>
			</div>
		</div>
		<!-- 商户状态-关闭弹框 -->
		<el-dialog :title="diaTitle" :visible.sync="StateShowStop" width="560px" :close-on-click-modal="false">
			<div class="auditCentent">
				<span>确认要停用该条计价吗？</span>
			</div>
			<div slot="footer" class="dialog-footer">
				<span class="btnOK mr_20" @click="addMenuBtn(2)">确 定</span>
				<span class="resetBtn" @click="hiddenRY">取 消</span>
			</div>
		</el-dialog>

		<!-- 商户状态-开启弹框 -->
		<el-dialog :title="diaTitle" :visible.sync="StateShowStart" width="560px" :close-on-click-modal="false">
			<div class="auditCentent">
				<span>确认要启用该条计价吗？</span>
			</div>
			<div slot="footer" class="dialog-footer">
				<span class="btnOK mr_20" @click="addMenuBtn(1)">确 定</span>
				<span class="resetBtn" @click="hiddenRY">取 消</span>
			</div>
		</el-dialog>
		<!-- 计价规则 -->
		<el-dialog
			:title="diaTitle"
			:visible.sync="PriceStatic"
			width="900px"
			:close-on-click-modal="false"
			:before-close="hiddenRY"
		>
			<div class="row-info clear">
				<div class="fl title-key"><i class="lhadmin lhadmin-wujiaoxing"></i>执行城市</div>
				<div class="fl list-cont b">
					<el-select v-model="dataMes.city_arr" placeholder="请选择" @change="changeBtndialogselect">
						<el-option
							v-for="item in dataMes.cityList"
							:key="item.id"
							:label="item.city_name"
							:value="`${item.id}|${item.city_name}`"
						></el-option>
					</el-select>
				</div>
			</div>
			<div class="row-info clear">
				<div class="fl title-key"><i class="lhadmin lhadmin-wujiaoxing" v-if="userType != 1"></i>执行商圈</div>
				<div class="fl list-cont a">
					<el-select v-model="dataMes.area_arr" placeholder="请选择" @change="changeBtndialogareaNext">
						<el-option
							v-for="item in dataMes.areaList"
							:key="item.id"
							:label="item.area_name"
							:value="`${item.id}|${item.area_name}`"
						></el-option>
					</el-select>
				</div>
			</div>
			<div class="row-info clear">
				<div class="fl title-key">执行店铺</div>
				<div class="fl list-cont a">
					<el-autocomplete
						class="inline-input"
						v-model="dataMes.shop_name"
						:fetch-suggestions="querySearchNext"
						placeholder="店铺名称"
						:trigger-on-focus="true"
						@select="handleSelectNext"
					></el-autocomplete>
				</div>
			</div>
			<div class="auditCentent">
				<div class="row-info clear">
					<div class="fl title-key"><i class="lhadmin lhadmin-wujiaoxing"></i>所属行业</div>
					<div class="fl list-cont a">
						<el-select v-model="dataMes.industry" @change="changeIndustry(dataMes.industry, '')">
							<el-option
								v-for="(item, index) in industryJobList"
								:key="index"
								:label="item.label_name"
								:value="item.id"
							></el-option>
						</el-select>
					</div>
				</div>
				<div class="row-info clear">
					<div class="fl title-key"><i class="lhadmin lhadmin-wujiaoxing"></i>岗位</div>
					<div class="fl list-cont b">
						<el-select v-model="dataMes.type_arr" placeholder="请选择" @change="changeBtndialogtypeNext">
							<el-option
								v-for="item in dataMes.mesarr"
								:key="item.id"
								:label="item.label_name"
								:value="`${item.id}|${item.label_name}`"
							></el-option>
						</el-select>
					</div>
				</div>
				<div class="row-info clear">
					<div class="fl title-key"><i class="lhadmin lhadmin-wujiaoxing"></i>计价方式</div>
					<div class="fl list-cont a">
						<el-select v-model="dataMes.type" placeholder="请选择">
							<el-option label="小时" value="1"></el-option>
						</el-select>
					</div>
				</div>
				<div class="row-info clear">
					<div class="fl title-key"><i class="lhadmin lhadmin-wujiaoxing"></i>店铺单价</div>
					<div class="fl list-cont b">
						<el-input v-model="dataMes.price_b" placeholder="请输入"></el-input>
					</div>
					<div class="fl title-key" style="width: 100px; text-align: left; margin-left: 10px;">元/小时</div>
					<div class="fl title-key"><i class="lhadmin lhadmin-wujiaoxing"></i>劳动者单价</div>

					<div class="fl list-cont b">
						<el-input v-model="dataMes.price_c" placeholder="请输入"></el-input>
					</div>
					<div class="fl title-key" style="width: 100px; text-align: left; margin-left: 10px;">元/小时</div>
				</div>
				<div class="row-info clear">
					<div class="fl title-key">需求描述</div>
					<div class="fl list-cont a">
						<el-input type="textarea" :rows="8" :cols="44" placeholder="请输入内容" v-model="dataMes.remark"></el-input>
					</div>
				</div>
			</div>
			<div slot="footer" class="dialog-footer">
				<span class="btnOK mr_20" @click="addMenuBtnAdd()">确 定</span>
				<span class="resetBtn" @click="hiddenRY()">取 消</span>
			</div>
		</el-dialog>
	</div>
</template>

<script>
var common = require('../../../static/tool.js')
// 123
import { fetchIndustryJob } from '@/api/label.js'
import { fetchAreaList, fetchShopList } from '@/api/shop.js'
import { fetchCityList } from '@/api/city.js'
import { fetchRulePriceList } from '@/api/price.js'

export default {
	name: 'ShopList',
	data() {
		return {
			id: '',
			ids: '',
			agreement: '',
			index: '',
			windowSizeHeight: document.documentElement.clientHeight, //浏览器可视化窗口的大小
			screenHeight: document.documentElement.clientHeight,
			manageInfo: JSON.parse(sessionStorage.getItem('manageInfo')), //登录信息
			userType: '',
			url: common.url,
			head_url: common.head_url,
			//搜索对应值
			agent_id: '',
			business_id: '', //所属商户ID
			business_name: '', //所属商户name
			industry_id: '', //行业

			searchIndustryArr: [], //行业

			demandList: [], //店铺列表
			diaTitle: '', //弹框title
			PriceStatic: false, //新增计价
			//下拉框数据
			cityList: [], //城市列表
			city_arr: '',
			city_id: '',
			city_name: '',
			areaList: [], //区域列表
			area_arr: '',
			area_id: '',
			area_name: '',
			shopList: [], //店铺列表
			shop_id: '', //店铺id
			shop_name: '', //店铺名
			mesarr: [], //任务标签列表
			dataMes: {
				id: '',
				industry: '',

				mesarr: [],
				type_arr: '',
				label_id: '',
				label_name: '',

				type: '',
				price_b: '',
				price_c: '',

				cityList: [],
				city_arr: '',
				city_id: '',
				city_name: '',

				areaList: [],
				area_arr: '',
				area_id: '',
				area_name: '',

				shopList: [],
				shop_name: '',
				shop_id: '',
				remark: ''
			},
			type_arr: '',
			label_id: '',
			label_name: '',
			StateShowStop: false, //人员状态-弹框关闭
			StateShowStart: false, //人员状态-弹框关闭
			//向分页组件传值
			total: 0,
			pageNum: 1,
			pageSizeNow: 20,
			industryJobList: [],
			localobList: JSON.parse(localStorage.getItem('industryJobList')),
			s_time_slot: '',
			status: '1',
			areaStatus: true,
			agent_reset: 0
		}
	},
	created() {
		if (this.$route.query.id) {
			this.id = this.$route.query.id //接收传参
			this.business_id = this.id
		}
		if (!sessionStorage.getItem('manageInfo')) {
			// 判断是否登录
			window.location = 'login.html'
			return
		}
		this.userType = this.manageInfo.user_info.type
	},
	mounted() {},
	// watch: {
	// 	areaList(newValue, oldValue) {
	// 		this.getPrice()
	// 	}
	// },
	methods: {
		// 代理商组件回传
		async setValue(arrVal) {
			console.log(arrVal)
			this.agent_id = arrVal.agent_id
			this.cityList = arrVal.city_list

			this.city_val = this.cityList[0].name
			this.city_id = this.cityList[0].id
			this.city_name = this.cityList[0].name
			this.city_arr = this.cityList[0].id + '|' + this.cityList[0].name
			this.industry_id = ""
			this.type_arr = ""
			this.getShopList() //获取店铺
			await this.listArea() //商圈列表
			await this.alljob_type()
			this.getPrice()
		},
		//获取店铺
		async getShopList() {
			try {
				let ret = await fetchShopList({
					sign_status: 30, //已合作的店铺
					status: 1, //启用的店铺
					fields: 'id,name,shop_sn,area_id,area_name,city_id,city_name',
					city_id: this.city_id,
					agent_id: this.agent_id
				})
				if (ret.list.length) {
					ret.list.forEach(item => {
						item.value = item.name
					})
					this.shopList = ret.list
				} else {
					this.shopList = []
				}
			} catch (err) {
				console.log(err)
			}
		},

		// 获取计价列表
		async getPrice() {
			try {
				var s_departmentIds_Arr = new Array()
				this.s_time_slot.forEach(element => {
					let [id, name] = element.split('|') // es6 数组解构赋值
					s_departmentIds_Arr.push(id.toString())
				})
				let label_Arr = []
				if (this.industry_id && !this.label_id) {
					let mesarr = this.searchIndustryArr.filter(x => x.id == this.industry_id)[0].children
					mesarr.forEach(it => {
						label_Arr.push(it.id)
					})
				}

				let res = await fetchRulePriceList({
					pageSize: this.pageSizeNow,
					page: this.pageNum,
					label_id: this.label_id || label_Arr.join(','),
					city_id: this.city_id,
					agent_id: this.agent_id,
					parent_id: this.industry_id,
					area_id: s_departmentIds_Arr.toString(),
					shop_id: this.shop_name ? this.shop_id : '',
					status: this.status
				})
				console.log(res)
				this.demandList = res.list
				this.total = res.count
			} catch (err) {
				console.log(err)
			}
		},
		// 获取城市列表
		async getcityList() {
			try {
				let ret = await fetchCityList()
				this.dataMes.cityList = ret.list
			} catch (err) {
				console.log('err:', err)
			}
		},

		//获取商圈列表
		async listArea() {
			try {
				this.s_time_slot = []
				let ret = await fetchAreaList({
					city_id: this.city_id,
					agent_id: this.agent_id
				})
				let area = []
				ret.list.forEach(item => {
					item.value = item.area_name
					if (item.id != 0) area.push(item)
				})

				this.areaList = area
			} catch (error) {
				console.log('error:', error)
			}
		},
		// 状态转换
		redactBtn(e, index) {
			this.ids = e.id
			this.index = index
			if (e.status == '1') {
				// 弹框1
				this.StateShowStop = true //状态关闭
				this.diaTitle = '温馨提示'
			} else {
				// 弹框2
				this.StateShowStart = true //状态开启
				this.diaTitle = '温馨提示'
			}
		},

		//隐藏商户弹框
		hiddenRY() {
			this.PriceStatic = false
			this.StateShowStart = false
			this.StateShowStop = false
			this.dataMes.id = ''
			this.dataMes.industry = ''
			this.dataMes.type_arr = ''
			this.dataMes.label_id = ''
			this.dataMes.label_name = ''
			this.dataMes.type = ''
			this.dataMes.price_b = ''
			this.dataMes.price_c = ''
			this.dataMes.city_arr = ''
			this.dataMes.city_id = ''
			this.dataMes.city_name = ''
			this.dataMes.area_arr = ''
			this.dataMes.area_id = ''
			this.dataMes.area_name = ''
			this.dataMes.shop_name = ''
			this.dataMes.shop_id = ''
			this.dataMes.remark = ''

			this.dataMes.shopList = this.shopList
			this.dataMes.areaList = this.areaList
			this.industryJobList = []
			this.dataMes.industry = ''
		},

		// 状态确认
		addMenuBtn(e) {
			let fn = new FormData()
			fn.append('id', this.ids)
			fn.append('status', e)

			this.$http.post(this.url + '/rule/priceAdd', fn).then(
				res => {
					console.log(res)
					if (res.data.msg == '操作成功！' || res.data.code == '200') {
						this.$message.success(res.data.msg)
						this.getPrice()
					} else if (res.data.code == '8886') {
						//code   8886  登录过期
						sessionStorage.clear()
						this.$alert('登录已过期，请重新登录 !', '提示', {
							confirmButtonText: '确定',
							callback: action => {
								window.location = 'login.html'
							}
						})
						return
					} else {
						this.$message.error(res.data.msg)
						return
					}
				},
				res => {
					this.$message.error('网络错误！')
					return
				}
			)
			//关闭弹框
			this.hiddenRY()
		},
		async changeBtndialog() {
			this.industry_id = ""
			this.type_arr = ""
			let [id, name] = this.city_arr.split('|')
			this.city_id = id.toString()
			this.city_name = name.toString()
			await this.getShopList() //获取店铺
			await this.listArea() //商圈列表
			await this.alljob_type()
			await this.getPrice()
		},

		changeBtndialogarea() {
			let [id, name] = this.area_arr.split('|')
			this.area_id = id.toString()
			this.area_name = name.toString()
		},

		async changeBtndialogselect() {
			let [id, name] = this.dataMes.city_arr.split('|')
			this.dataMes.city_id = id.toString()
			this.dataMes.city_name = name.toString()
			//显示对应城市的的商圈
			this.dataMes.areaList = []
			this.dataMes.area_arr = ''
			this.dataMes.area_id = ''
			this.dataMes.area_name = ''

			this.dataMes.shopList = []
			this.dataMes.shop_id = ''
			this.dataMes.shop_name = ''

			this.industryJobList = []
			this.dataMes.industry = ''

			this.getIndustryJob()

			let ret = await fetchAreaList({
				city_id: this.dataMes.city_id,
				city_name: this.dataMes.city_name
			})
			let area = []
			ret.list.forEach(item => {
				item.value = item.area_name
				if (item.id != 0) area.push(item)
			})
			this.dataMes.areaList = area
		},

		changeBtndialogareaNext() {
			let [id, name] = this.dataMes.area_arr.split('|')
			this.dataMes.area_id = id.toString()
			this.dataMes.area_name = name.toString()

			this.dataMes.shop_name = ''
			this.dataMes.shop_id = ''
			this.dataMes.shopList = []

			this.industryJobList = []
			this.dataMes.industry = ''
			this.getIndustryJob()
			//获取商铺列表
			let fn = new FormData()
			fn.append('area_id', this.dataMes.area_id) //对应商圈下的店铺
			fn.append('fields', 'id,name,shop_sn,area_id,area_name,city_id,city_name') //需要返回的数据
			this.$http.post(this.url + '/shop/getListForSearch', fn).then(
				res => {
					// console.log(res.data.data);
					if (res.data.msg == '查询成功' || res.data.code == '200') {
						if (res.data.data != null) {
							res.data.data.list.forEach(item => {
								item.value = item.name
							})
							this.dataMes.shopList = res.data.data.list
						} else {
							this.dataMes.shopList = []
						}
					} else if (res.data.code == '8886') {
						//code   8886  登录过期
						sessionStorage.clear()
						this.$alert('登录已过期，请重新登录 !', '提示', {
							confirmButtonText: '确定',
							callback: action => {
								window.location = 'login.html'
							}
						})
						return
					} else {
						this.$message.error(res.data.msg)
						return
					}
				},
				res => {
					this.$message.error('网络错误！')
					return
				}
			)
		},

		changeIndustry(val, type) {
			if (!val && type == 'search') {
				this.mesarr = []
				this.type_arr = ''
				this.label_id = ''
			} else if (type == 'search') {
				//搜索行业监听
				this.mesarr = this.searchIndustryArr.filter(x => x.id == val)[0].children
				this.type_arr = ''
				this.label_id = ''
			} else {
				// 新增计价 行业监听
				this.dataMes.type_arr = ''
				this.dataMes.mesarr = this.industryJobList.filter(x => x.id == this.dataMes.industry)[0].children
			}
		},

		changeBtndialogtype() {
			if (this.type_arr) {
				let [id, name] = this.type_arr.split('|')
				this.label_id = id.toString()
				this.label_name = name.toString()
			} else {
				this.label_id = ''
				this.label_name = ''
			}
		},

		changeBtndialogtypeNext() {
			let [id, name] = this.dataMes.type_arr.split('|')
			this.dataMes.label_id = id.toString()
			this.dataMes.label_name = name.toString()
		},

		shearchBtn() {
			// 搜索
			this.pageNum = 1
			this.getPrice()
		},

		resetBtn() {
			//重置
			this.resetDataAdd() //重置请求数据
			this.pageNum = 1
			this.getPrice()
		},

		resetDataAdd() {
			this.type_arr = ''
			this.label_id = ''
			this.label_name = ''
			this.city_arr = ''
			this.city_id = ''
			this.city_name = ''
			this.area_arr = ''
			this.area_id = ''
			this.area_name = ''
			this.shop_id = ''
			this.shop_name = ''
			this.industry_id = ''
			this.agent_reset += 1
		},
		//标签接口 搜索获取
		async alljob_type() {
			this.mesarr = []
			try {
        		let ret = await fetchIndustryJob({
					city_id: this.city_id
				})
				if(ret.length>0){
					this.searchIndustryArr = ret
				}else{
					this.searchIndustryArr = []
				}
			} catch (err) {
				console.log(err)
			}
		},

		goToEdit(row) {
			//编辑页面
			this.$router.push({
				path: '/merchantsEdit',
				query: {
					id: row.id
				}
			})
		},

		goToTag(row) {
			this.PriceStatic = true
			this.dataMes.mesarr = []
			if (row) {
				this.diaTitle = '修改计价规则'
				// 详情查询
				let fn = new FormData()
				fn.append('id', row.id)
				this.$http.post(this.url + '/rule/shopInfo', fn).then(
					res => {
						if (res.data.msg == '查询成功！' || res.data.code == '200') {
							if (res.data.data != null) {
								var message = res.data.data
								this.dataMes.id = row.id
								// this.dataMes.industry = message.industry
								this.dataMes.type_arr = message.label_id + '|' + message.label_name
								this.dataMes.label_id = message.label_id.toString()
								this.dataMes.label_name = message.label_name
								this.dataMes.type = '1'
								this.dataMes.price_b = message.price_b
								this.dataMes.price_c = message.price_c
								this.dataMes.city_arr = message.city_id + '|' + message.city_name
								this.dataMes.city_id = message.city_id.toString()
								this.dataMes.city_name = message.city_name
								if (message.area_id == 0) {
									this.dataMes.area_arr = ''
									this.dataMes.area_id = ''
									this.dataMes.area_name = ''
								} else {
									this.dataMes.area_arr = message.area_id + '|' + message.area_name
									this.dataMes.area_id = message.area_id.toString()
									this.dataMes.area_name = message.area_name
								}

								this.dataMes.shop_id = message.shop_id
								this.dataMes.shop_name = message.shop_name
								// this.next_shop_sn = message.shop_sn
								this.dataMes.remark = message.info
								// 城市信息不为空
								if (this.dataMes.city_id != '' && this.dataMes.city_name != '') {
									let fn = new FormData()
									fn.append('city_id', this.dataMes.city_id)
									fn.append('city_name', this.dataMes.city_name)
									this.$http.post(this.url + '/area/list', fn).then(
										res => {
											if (res.data.msg == '查询成功' || res.data.code == '200') {
												if (res.data.data != null) {
													res.data.data.list.forEach(item => {
														item.value = item.area_name
													})
													this.dataMes.areaList = res.data.data.list
												} else {
													this.dataMes.areaList = []
												}
											} else if (res.data.code == '8886') {
												//code   8886  登录过期
												sessionStorage.clear()
												this.$alert('登录已过期，请重新登录 !', '提示', {
													confirmButtonText: '确定',
													callback: action => {
														window.location = 'login.html'
													}
												})
												return
											} else {
												this.$message.error(res.data.msg)
												return
											}
										},
										res => {
											this.$message.error('网络错误！')
											return
										}
									)
								}
								// 商圈信息不为空
								if (this.dataMes.area_id != '') {
									let fn = new FormData()
									fn.append('area_id', this.dataMes.area_id) //对应商圈下的店铺
									fn.append('fields', 'id,name,shop_sn,area_id,area_name,city_id,city_name') //需要返回的数据
									this.$http.post(this.url + '/shop/getListForSearch', fn).then(
										res => {
											// console.log(res.data.data);
											if (res.data.msg == '查询成功' || res.data.code == '200') {
												if (res.data.data != null) {
													res.data.data.list.forEach(item => {
														item.value = item.name
													})
													this.dataMes.shopList = res.data.data.list
												} else {
													this.dataMes.shopList = []
												}
											} else if (res.data.code == '8886') {
												//code   8886  登录过期
												sessionStorage.clear()
												this.$alert('登录已过期，请重新登录 !', '提示', {
													confirmButtonText: '确定',
													callback: action => {
														window.location = 'login.html'
													}
												})
												return
											} else {
												this.$message.error(res.data.msg)
												return
											}
										},
										res => {
											this.$message.error('网络错误！')
											return
										}
									)
								}

								this.dataMes.industry = message.industry
								let fn = new FormData()
								fn.append('city_id', this.dataMes.city_id)

								this.$http.post(this.url + '/label/industryJob', fn).then(
									res => {
										if (res.data.msg == '查询成功' || res.data.code == '200') {
											this.industryJobList = res.data.data
											this.dataMes.mesarr = this.industryJobList.filter(x => x.id == +this.dataMes.industry)[0].children
										} else if (res.data.code == '8886') {
											//code   8886  登录过期
											sessionStorage.clear()
											this.$alert('登录已过期，请重新登录 !', '提示', {
												confirmButtonText: '确定',
												callback: action => {
													window.location = 'login.html'
												}
											})
											return
										} else {
											this.$message.error(res.data.msg)
											return
										}
									},
									res => {
										this.$message.error('网络错误！')
										return
									}
								)
								// message.industry
								// var industryName = message.industry
								// console.log(industryName)
								// console.log(this.industryJobList.filter(x => x.label_name == industryName))
								// this.dataMes.industry = this.industryJobList.filter(x => x.label_name == industryName)[0].id || ''
								// }
							} else {
							}
						} else if (res.data.code == '8886') {
							//code   8886  登录过期
							sessionStorage.clear()
							this.$alert('登录已过期，请重新登录 !', '提示', {
								confirmButtonText: '确定',
								callback: action => {
									window.location = 'login.html'
								}
							})
							return
						} else {
							this.$message.error(res.data.msg)
							return
						}
					},
					res => {
						this.$message.error('网络错误！')
						return
					}
				)
			} else {
				this.diaTitle = '新增计价规则'
			}
		},

		//店铺的自动完成
		querySearch(queryString, cb) {
			var restaurants = this.shopList
			var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants
			// 调用 callback 返回建议列表的数据
			cb(results)
		},
		createFilter(queryString) {
			return restaurant => {
				return restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0
			}
		},
		handleSelect(item) {
			this.shop_id = item.id
			this.next_shop_sns = item.shop_sn
		},

		//店铺的自动完成
		querySearchNext(queryString, cb) {
			var restaurants = this.dataMes.shopList
			var results = queryString ? restaurants.filter(this.createFilterNext(queryString)) : restaurants
			// 调用 callback 返回建议列表的数据
			cb(results)
		},
		createFilterNext(queryString) {
			return restaurant => {
				return restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0
			}
		},
		handleSelectNext(item) {
			console.log(item)
			this.dataMes.shop_id = item.id
			this.next_shop_sn = item.shop_sn
			// 123
			this.getIndustryJob()
			if (item.city_name) {
				this.dataMes.city_arr = `${item.city_id}|${item.city_name}`
				this.dataMes.city_id = item.city_id
				this.dataMes.city_name = item.city_name
			}

			if (item.area_name) {
				this.dataMes.area_arr = item.area_id + '|' + item.area_name
				this.dataMes.area_id = item.area_id.toString()
				this.dataMes.area_name = item.area_name
			}
		},

		//分页组件->子组件传值
		onChildValue(item) {
			this.pageNum = item[0]
			this.pageSizeNow = item[1]
			// if (this.areaList.length > 0) {
			// this.getPrice()
			// }
			//上面的列表数据
			this.getPrice()
		},

		//添加计价规则
		addMenuBtnAdd() {
			console.log('添加计价规则')
			if (this.dataMes.industry == '') {
				this.$message.error('请选择所属行业！')
				return false
			}

			if (this.dataMes.label_id == '') {
				this.$message.error('请选择岗位！')
				return false
			}

			if (this.dataMes.type == '') {
				this.$message.error('请选择计价方式！')
				return false
			}
			if (this.dataMes.price_b == '') {
				this.$message.error('请输入店铺单价！')
				return false
			}
			if (this.dataMes.price_b < 0) {
				this.$message.error('店铺单价不可为负数！')
				return false
			}
			if (this.dataMes.price_c == '') {
				this.$message.error('请输入劳动者单价！')
				return false
			}
			if (this.dataMes.price_c < 0) {
				this.$message.error('劳动者单价单价不可为负数！')
				return false
			}
			if (this.dataMes.city_id == '') {
				this.$message.error('请选择执行城市！')
				return false
			}
			if (this.dataMes.area_id == '' && this.userType != 1) {
				this.$message.error('请选择执行商圈！')
				return false
			}
			// if (this.dataMes.shop_name == '') {
			//   this.$message.error('请选择执行店铺！')
			//   return false
			// }
			let fn = new FormData()
			if (this.dataMes.id) {
				fn.append('id', this.dataMes.id)
			}
			fn.append('industry', this.dataMes.industry)
			fn.append('label_name', this.dataMes.label_name)
			fn.append('city_id', this.dataMes.city_id)
			fn.append('label_id', this.dataMes.label_id)
			fn.append('label_name', this.dataMes.label_name)
			fn.append('city_name', this.dataMes.city_name)
			fn.append('area_id', this.dataMes.area_id)
			if (this.dataMes.shop_name == '') {
				this.dataMes.shop_id = ''
			}
			fn.append('shop_id', this.dataMes.shop_id)
			fn.append('price_b', this.dataMes.price_b)
			fn.append('price_c', this.dataMes.price_c)
			fn.append('info', this.dataMes.remark)

			this.$http.post(this.url + '/rule/priceAdd', fn).then(
				res => {
					console.log(res)
					if (res.data.msg == '操作成功！' || res.data.code == '200') {
						this.$message.success(res.data.msg)
						this.getPrice()
					} else if (res.data.code == '8886') {
						//code   8886  登录过期
						sessionStorage.clear()
						this.$alert('登录已过期，请重新登录 !', '提示', {
							confirmButtonText: '确定',
							callback: action => {
								window.location = 'login.html'
							}
						})
						return
					} else {
						this.$message.error(res.data.msg)
						return
					}
				},
				res => {
					this.$message.error('网络错误！')
					return
				}
			)
			// 重置弹出层的内容
			this.hiddenRY()
		},

		async getIndustryJob() {
			try {
				let ret = await fetchIndustryJob({
					city_id: this.dataMes.city_id,
					shop_sn: this.next_shop_sn
				})
				this.industryJobList = ret
			} catch (err) {
				console.log(err)
			}
		},

		//全选-取消全选商圈
		selectAllArea() {
			let arr = []
			this.areaList.forEach(item => {
				arr.push(`${item.id}|${item.area_name}`)
			})
			if (this.areaStatus == true) {
				this.s_time_slot = arr
			} else {
				this.s_time_slot = []
			}
			this.areaStatus = !this.areaStatus
			// this.shearchBtn()
		}
	},
	filters: {}
}
</script>

<style scoped>
.search_box {
	width: 790px;
}
.auditCentent .labels {
	min-height: 100px;
}
.auditCentent .labels .labels_label {
	float: left;
	cursor: pointer;
}
.check_label {
	background: var(--purple4);
	color: #fff;
	border: none;
}
.pdf {
	width: 860px;
	height: 600px;
}
.main_user {
	background: var(--zfy-red);
	color: #fff;
	text-decoration: none;
	padding: 2px 4px;
	border-radius: 4px;
}
@media (max-width: 767.78px) {
	.titleBox {
		height: 40px;
	}
}

.row-info {
	padding: 10px 0;
}
</style>



// WEBPACK FOOTER //
// src/components/shopPrice/ListOld.vue